/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rainful.echo;

import java.io.Serializable;
import java.util.HashMap;

/**
 *
 * @author Administrator
 */
public class HostNeedEcho extends Echo {

    protected HashMap<String, Serializable> needMap;

    public HostNeedEcho(String subjectName) {
        super(subjectName);
        needMap = new HashMap<String, Serializable>();
    }

    public HostNeedEcho(Echo echo) {
        super(echo);
        needMap = new HashMap<String, Serializable>();
    }

    public HostNeedEcho(Echo echo, String needString) {
        super(echo);
        String[] needs = needString.split(",");
        needMap = new HashMap<String, Serializable>();
        for (int i = 0; i < needs.length; i++) {
            needMap.put(needs[i], null);
        }
    }

    @Override
    public void execute(EchoSpace space) {
        for (String key : needMap.keySet()) {
            needMap.put(key, (Serializable) space.get(key));
        }
    }
}
